<php>res_load(PUBLIC_PATH."/BoxAddon/Upload/_static/css/default.css","css")</php>
<php>res_load(PUBLIC_PATH."/BoxAddon/Upload/_static/js/swfupload.js","js")</php>
<php>res_load(PUBLIC_PATH."/BoxAddon/Upload/_static/js/handlers.js","js")</php>
<php>res_load(PUBLIC_PATH."/BoxAddon/Upload/_static/js/swfupload.queue.js","js")</php>
<php>res_load(PUBLIC_PATH."/BoxAddon/Upload/_static/js/fileprogress.js","js")</php>
<style>
.progressWrapper {
	width: 100%
}
.modal-footer object {
    position: absolute;
    z-index: 99;
    left: 0;
	top:0px;
}
#swfupload_modal .modal-foot{padding-top: 21px;
    padding-bottom: 33px;}
#swfupload_modal .modal-title{ color:#fff}	
</style>

<div class="modal fade in"  id="swfupload_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
          <div class="modal-content">
            <div class="modal-header label-primary">
              <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
              <h4 class="modal-title" id="myModalLabel">上传文件文件</h4>
            </div>
            <div class="modal-body">
              <!--<div  class="fl" style="width:60px;">
                <fd  id="element_id" ></fd>
              </div>-->
              <!--<div class="fl">支持xls xlsx doc docx pdf jpg jpeg gif png dad 格式</div>-->
              <div style="clear:both"></div>
              <div class="padding-md" id="fsUploadProgress"> </div>
            </div>
            <div class="modal-footer text-center">
			 
			  <div  class="fl posi-rela" style="color:#fff; padding:0;">
                <fd id="element_id"></fd>
				<a href="#" class="btn btn-primary posi-abso modal_upload_bnt" style="z-index:1; left:0;top:0px"><span class="glyphicon glyphicon-plus"></span>上传文件</a>
              </div>
			<button style="display:none" type="button" class="btn btn-primary" id="btnCancel">取消上传</button>
              <button type="button" hiddenCall="" id="hiddenCall" class="btn btn-primary fl"  data-dismiss="modal" aria-label="Close" style="margin-left:141px">确定</button>
			   
            </div>
          </div>
        </div>
      </div> 
 <script>
var swfu;
var show_modal_int=0;
var upload_obj;
var progress_array={};//上传进度数
var maxUpload=0;
var upload_text=$(".modal-footer .modal_upload_bnt").html();
//打开上传模态框
function show_swfupload_modal(obj){
	maxUpload=$(obj).attr("maxUpload");
	upload_obj=obj;
	show_modal_int=$(obj).attr("show_modal_int");
	var hiddenCall=$(obj).attr("hiddenCall");
	if(hiddenCall){
		$("#swfupload_modal").find("#hiddenCall").attr("hiddenCall",hiddenCall);
	}else{
		$("#swfupload_modal").find("#hiddenCall").attr("hiddenCall","");
	}
	$("#swfupload_modal").modal("show");
	var obj=$("[show_modal_int='"+show_modal_int+"']");
	var html=$(obj).next().html();
	$("#fsUploadProgress").html(html);
}


//关闭上传模态框
$('#swfupload_modal').on('hidden.bs.modal', function (e) {
	var hiddenCall=$("#swfupload_modal").find("#hiddenCall").attr("hiddenCall");
	var obj=$("[show_modal_int='"+show_modal_int+"']");
	var progressContainer=$("#fsUploadProgress").find(".progressContainer.blue");
	var html="";
	var uploadList=new Array();
	$.each(progressContainer,function(i,v){
		html+=$(v).prop("outerHTML");
		var row={
				file_url:$(v).find("input").eq(0).val(),
				file_name:$(v).find("input").eq(1).val()
			};
		uploadList.push(row);
	})
	var uploadListStr=JSON.stringify(uploadList);
	obj.prev().val(uploadListStr);
	obj.next().html(html);
	$("#fsUploadProgress").html("");
	if(hiddenCall){
		eval(hiddenCall(show_modal_int))
	}
})


$(function(){
/*********文件上传*********/
var settings_object = {
		upload_url : '<php>echo AdminUrl;</php>/BoxAddon/Upload/Index/upload/path/<{$path}>/exts/<{$exts}>',
		flash_url : '__PUBLIC__/BoxAddon/Upload/_static/js/swfupload.swf',
		file_post_name : "imgFile",
		use_query_string : false,
		requeue_on_error : false,
		http_success : [201, 202],
		assume_success_timeout : 0,
		file_types : "*.*",
		file_types_description: "Web Image Files",
		file_size_limit : "1024000",
		file_upload_limit : 1000,
		file_queue_limit : 20,
		debug : false,
		custom_settings : {  
		  progressTarget : "fsUploadProgress",  
		  cancelButtonId : "btnCancel" ,
		},  
		prevent_swf_caching : false,
		preserve_relative_urls : false,
		button_placeholder_id : "element_id",
	  // button_image_url : oyy.settings.basePath+"/assets/image/oyys/xjd_39.png",
		button_width : 104,
		button_height : 42,
		button_action : SWFUpload.BUTTON_ACTION.SELECT_FILES,
		button_disabled : false,
		button_cursor : SWFUpload.CURSOR.HAND,
		button_window_mode : SWFUpload.WINDOW_MODE.TRANSPARENT,
		swfupload_loaded_handler : swfUploadLoaded,
		file_queued_handler : fileQueued,
		file_queue_error_handler : fileQueueError,
		file_dialog_complete_handler : fileDialogComplete,
		upload_start_handler : uploadStart,
		upload_progress_handler : uploadProgress,
		upload_error_handler : uploadError,
		upload_success_handler : uploadSuccess,
	   upload_complete_handler : uploadComplete,	
    };	
	swfu = new SWFUpload(settings_object);//实例化一个SWFUpload，传入参数配置对	
})
 </script>